import allure
import pytest
from page.mailList.orgPage import OrgPage
from selenium.webdriver.common.by import By
from tools.read_yaml import read_yaml

org_create_datas = read_yaml(".\caseData\mailList\orgTestData.yaml", 'org_create')

@allure.epic("通讯录管理")
@allure.feature("部门管理")
class TestOrg():

    @allure.story("创建部门")
    @allure.title("{title}")
    @pytest.mark.parametrize("title, case_data", [(case_data.get('title'), case_data) for case_data in org_create_datas])
    def test_create_org(self, in_and_out, case_data, title):
        org_page = OrgPage(in_and_out)
        org_page.create_org(case_data.get('data').get("org_name"))
        # assert org_page.my_get_text((By.XPATH, "//*[@text='该部门已存在']")) == case_data.get("expect")
        assert org_page.my_find_element((By.XPATH, "//*[@text='{}']".format(case_data.get("expect"))))